<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>统计报表 - 工业管道安全巡检系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-gray-100">
    <!-- 顶部导航栏 -->
    <nav class="bg-blue-600 text-white p-4 shadow-lg">
        <div class="flex justify-between items-center">
            <h1 class="text-xl font-bold">统计报表</h1>
            <div class="flex space-x-2">
                <button class="bg-green-500 hover:bg-green-600 px-4 py-2 rounded-lg">
                    <i class="fas fa-download mr-2"></i>导出报表
                </button>
                <button class="bg-purple-500 hover:bg-purple-600 px-4 py-2 rounded-lg">
                    <i class="fas fa-print mr-2"></i>打印
                </button>
            </div>
        </div>
    </nav>

    <div class="flex">
        <!-- 侧边栏 -->
        <aside class="bg-white w-64 min-h-screen shadow-lg">
            <nav class="p-4">
                <ul class="space-y-2">
                    <li><a href="#" class="flex items-center p-3 text-gray-700 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-tachometer-alt w-6"></i>
                        <span class="ml-3">主控制台</span>
                    </a></li>
                    <li><a href="#" class="flex items-center p-3 bg-purple-50 text-purple-600 rounded-lg">
                        <i class="fas fa-chart-bar w-6"></i>
                        <span class="ml-3">统计报表</span>
                    </a></li>
                </ul>
            </nav>
        </aside>

        <!-- 主内容区 -->
        <main class="flex-1 p-6">
            <!-- 时间选择器 -->
            <div class="bg-white p-4 rounded-lg shadow mb-6">
                <div class="flex justify-between items-center">
                    <div class="flex space-x-4 items-center">
                        <label class="text-sm font-medium text-gray-700">统计时间:</label>
                        <input type="date" value="2025-01-01" class="px-3 py-2 border border-gray-300 rounded-lg">
                        <span class="text-gray-500">至</span>
                        <input type="date" value="2025-01-17" class="px-3 py-2 border border-gray-300 rounded-lg">
                        <button class="bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600">
                            <i class="fas fa-search mr-2"></i>查询
                        </button>
                    </div>
                    <div class="flex space-x-2">
                        <button class="bg-gray-100 text-gray-700 px-3 py-2 rounded-lg text-sm">今天</button>
                        <button class="bg-gray-100 text-gray-700 px-3 py-2 rounded-lg text-sm">本周</button>
                        <button class="bg-blue-100 text-blue-700 px-3 py-2 rounded-lg text-sm">本月</button>
                        <button class="bg-gray-100 text-gray-700 px-3 py-2 rounded-lg text-sm">本年</button>
                    </div>
                </div>
            </div>

            <!-- 总览数据卡片 -->
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
                <div class="bg-white p-6 rounded-lg shadow">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500 text-sm">巡检任务</p>
                            <p class="text-3xl font-bold text-blue-600">156</p>
                            <p class="text-sm text-green-600 mt-1">
                                <i class="fas fa-arrow-up mr-1"></i>+12.5%
                            </p>
                        </div>
                        <div class="p-3 bg-blue-100 rounded-lg">
                            <i class="fas fa-clipboard-check text-blue-600 text-2xl"></i>
                        </div>
                    </div>
                </div>

                <div class="bg-white p-6 rounded-lg shadow">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500 text-sm">发现缺陷</p>
                            <p class="text-3xl font-bold text-red-600">43</p>
                            <p class="text-sm text-red-600 mt-1">
                                <i class="fas fa-arrow-up mr-1"></i>+8.3%
                            </p>
                        </div>
                        <div class="p-3 bg-red-100 rounded-lg">
                            <i class="fas fa-exclamation-triangle text-red-600 text-2xl"></i>
                        </div>
                    </div>
                </div>

                <div class="bg-white p-6 rounded-lg shadow">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500 text-sm">处理完成</p>
                            <p class="text-3xl font-bold text-green-600">38</p>
                            <p class="text-sm text-green-600 mt-1">
                                <i class="fas fa-arrow-up mr-1"></i>+15.2%
                            </p>
                        </div>
                        <div class="p-3 bg-green-100 rounded-lg">
                            <i class="fas fa-check-circle text-green-600 text-2xl"></i>
                        </div>
                    </div>
                </div>

                <div class="bg-white p-6 rounded-lg shadow">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500 text-sm">完成率</p>
                            <p class="text-3xl font-bold text-purple-600">88.4%</p>
                            <p class="text-sm text-green-600 mt-1">
                                <i class="fas fa-arrow-up mr-1"></i>+3.1%
                            </p>
                        </div>
                        <div class="p-3 bg-purple-100 rounded-lg">
                            <i class="fas fa-percentage text-purple-600 text-2xl"></i>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
                <!-- 巡检趋势图 -->
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-semibold mb-4">巡检任务趋势</h3>
                    <canvas id="inspectionTrendChart" height="250"></canvas>
                </div>

                <!-- 缺陷等级分布 -->
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-semibold mb-4">缺陷等级分布</h3>
                    <canvas id="defectLevelChart" height="250"></canvas>
                </div>

                <!-- 人员效率统计 -->
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-semibold mb-4">人员效率统计</h3>
                    <canvas id="staffEfficiencyChart" height="250"></canvas>
                </div>

                <!-- 线路状态分析 -->
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-semibold mb-4">线路状态分析</h3>
                    <canvas id="pipelineStatusChart" height="250"></canvas>
                </div>
            </div>

            <!-- 详细数据表格 -->
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                <!-- 线路巡检统计 -->
                <div class="bg-white rounded-lg shadow">
                    <div class="p-4 border-b">
                        <h3 class="text-lg font-semibold">线路巡检统计</h3>
                    </div>
                    <div class="p-4">
                        <div class="overflow-x-auto">
                            <table class="w-full">
                                <thead>
                                    <tr class="text-left text-sm text-gray-500 border-b">
                                        <th class="pb-2">线路名称</th>
                                        <th class="pb-2">巡检次数</th>
                                        <th class="pb-2">发现缺陷</th>
                                        <th class="pb-2">完成率</th>
                                    </tr>
                                </thead>
                                <tbody class="text-sm">
                                    <tr class="border-b">
                                        <td class="py-3">输油主干线A-001</td>
                                        <td class="py-3">45</td>
                                        <td class="py-3 text-red-600">8</td>
                                        <td class="py-3 text-green-600">95.6%</td>
                                    </tr>
                                    <tr class="border-b">
                                        <td class="py-3">输油支线B-002</td>
                                        <td class="py-3">32</td>
                                        <td class="py-3 text-red-600">5</td>
                                        <td class="py-3 text-green-600">87.5%</td>
                                    </tr>
                                    <tr class="border-b">
                                        <td class="py-3">输油支线C-003</td>
                                        <td class="py-3">28</td>
                                        <td class="py-3 text-red-600">3</td>
                                        <td class="py-3 text-green-600">92.9%</td>
                                    </tr>
                                    <tr>
                                        <td class="py-3">输油支线D-004</td>
                                        <td class="py-3">23</td>
                                        <td class="py-3 text-red-600">2</td>
                                        <td class="py-3 text-green-600">91.3%</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <!-- 人员工作量统计 -->
                <div class="bg-white rounded-lg shadow">
                    <div class="p-4 border-b">
                        <h3 class="text-lg font-semibold">人员工作量统计</h3>
                    </div>
                    <div class="p-4">
                        <div class="space-y-4">
                            <div class="flex items-center justify-between p-3 bg-blue-50 rounded-lg">
                                <div class="flex items-center space-x-3">
                                    <img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=40&h=40&fit=crop&crop=face" 
                                         alt="头像" class="w-10 h-10 rounded-full">
                                    <div>
                                        <p class="font-medium text-gray-800">李巡检员</p>
                                        <p class="text-sm text-gray-500">巡检任务 47次</p>
                                    </div>
                                </div>
                                <div class="text-right">
                                    <div class="text-lg font-semibold text-blue-600">97.2%</div>
                                    <div class="text-xs text-gray-500">完成率</div>
                                </div>
                            </div>

                            <div class="flex items-center justify-between p-3 bg-green-50 rounded-lg">
                                <div class="flex items-center space-x-3">
                                    <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop&crop=face" 
                                         alt="头像" class="w-10 h-10 rounded-full">
                                    <div>
                                        <p class="font-medium text-gray-800">王巡检员</p>
                                        <p class="text-sm text-gray-500">巡检任务 38次</p>
                                    </div>
                                </div>
                                <div class="text-right">
                                    <div class="text-lg font-semibold text-green-600">94.7%</div>
                                    <div class="text-xs text-gray-500">完成率</div>
                                </div>
                            </div>

                            <div class="flex items-center justify-between p-3 bg-purple-50 rounded-lg">
                                <div class="flex items-center space-x-3">
                                    <img src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=40&h=40&fit=crop&crop=face" 
                                         alt="头像" class="w-10 h-10 rounded-full">
                                    <div>
                                        <p class="font-medium text-gray-800">张巡检员</p>
                                        <p class="text-sm text-gray-500">巡检任务 34次</p>
                                    </div>
                                </div>
                                <div class="text-right">
                                    <div class="text-lg font-semibold text-purple-600">91.2%</div>
                                    <div class="text-xs text-gray-500">完成率</div>
                                </div>
                            </div>

                            <div class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg">
                                <div class="flex items-center space-x-3">
                                    <img src="https://images.unsplash.com/photo-1519345182560-3f2917c472ef?w=40&h=40&fit=crop&crop=face" 
                                         alt="头像" class="w-10 h-10 rounded-full">
                                    <div>
                                        <p class="font-medium text-gray-800">刘维护员</p>
                                        <p class="text-sm text-gray-500">消缺任务 26次</p>
                                    </div>
                                </div>
                                <div class="text-right">
                                    <div class="text-lg font-semibold text-yellow-600">88.5%</div>
                                    <div class="text-xs text-gray-500">完成率</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // 巡检任务趋势图
        const ctx1 = document.getElementById('inspectionTrendChart').getContext('2d');
        new Chart(ctx1, {
            type: 'line',
            data: {
                labels: ['1月1日', '1月5日', '1月10日', '1月15日'],
                datasets: [{
                    label: '巡检任务',
                    data: [32, 45, 38, 41],
                    borderColor: 'rgb(59, 130, 246)',
                    backgroundColor: 'rgba(59, 130, 246, 0.1)',
                    tension: 0.4
                }, {
                    label: '发现缺陷',
                    data: [8, 12, 9, 14],
                    borderColor: 'rgb(239, 68, 68)',
                    backgroundColor: 'rgba(239, 68, 68, 0.1)',
                    tension: 0.4
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false
            }
        });

        // 缺陷等级分布图
        const ctx2 = document.getElementById('defectLevelChart').getContext('2d');
        new Chart(ctx2, {
            type: 'doughnut',
            data: {
                labels: ['紧急', '严重', '一般'],
                datasets: [{
                    data: [8, 15, 20],
                    backgroundColor: ['#EF4444', '#F59E0B', '#3B82F6']
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false
            }
        });

        // 人员效率统计
        const ctx3 = document.getElementById('staffEfficiencyChart').getContext('2d');
        new Chart(ctx3, {
            type: 'bar',
            data: {
                labels: ['李巡检员', '王巡检员', '张巡检员', '刘维护员'],
                datasets: [{
                    label: '完成率(%)',
                    data: [97.2, 94.7, 91.2, 88.5],
                    backgroundColor: ['#3B82F6', '#10B981', '#8B5CF6', '#F59E0B']
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 100
                    }
                }
            }
        });

        // 线路状态分析
        const ctx4 = document.getElementById('pipelineStatusChart').getContext('2d');
        new Chart(ctx4, {
            type: 'radar',
            data: {
                labels: ['安全性', '完整性', '可靠性', '维护性', '经济性'],
                datasets: [{
                    label: '当前状态',
                    data: [85, 78, 92, 88, 75],
                    borderColor: 'rgb(59, 130, 246)',
                    backgroundColor: 'rgba(59, 130, 246, 0.2)'
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    r: {
                        beginAtZero: true,
                        max: 100
                    }
                }
            }
        });
    </script>
</body>
</html>